#!/usr/bin/env python
# coding=utf-8

import thriftpy2
pingpong_thrift = thriftpy2.load("pingpong.thrift", 
                                module_name='pingpong_thrift')
from thriftpy2.rpc import make_client
from datetime import datetime
import msgpack
import zlib
import pickle

client = make_client(pingpong_thrift.PingPong, '127.0.0.1', 6000)

def get(method_name:str, **kwargs):
    request = pingpong_thrift.St_Query_Req()
    request.method_name = method_name 
    request.params = msgpack.packb(kwargs)

    data = client.query(request)
    return data

response = get("read_minute_quotes", symbol='000001.XSHE', 
           start_dt="2019-01-04 09:30:00", 
           end_dt="2019-02-04 09:30:00")
if response.status:
    msg = response.msg
    # 解压
    data = zlib.decompress(msg)
    # unpickle
    pd_data = data = pickle.loads(data)
    print(pd_data)

else:
    err = response.error
